package com.zdkj.subway.stm.util;/**
 * @author 陈博
 * @date 2020/2/7 0007 21:31
 */

import com.zdkj.common.core.exceltools.ExcelUtil;
import com.zdkj.common.core.exceltools.MultipartFileToFile;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;

/**
 * @program: zdkj
 *
 * @description:导入导出重复代码抽取
 *
 * @author: chen
 *
 * @create: 2020-02-07 21:31
 **/
@Slf4j
@Component
public class ExcelUtilsStm {
    public static Sheet inport(MultipartFile multipartFile){
        Workbook workbook = null;
        try {
            File file = MultipartFileToFile.multipartFileToFile(multipartFile);
            workbook = ExcelUtil.chooseWorkbook(file);
            /**
             * 删除缓存文件
             */
            MultipartFileToFile.delteTempFile(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Sheet sheet = workbook.getSheetAt(0);

        return sheet;
    }
}
